#include "bullet.h"

Bullet::Bullet()
{
    m_bullet.load(":/res/bullet.png");

    b_x=(350-m_bullet.width())*0.5;
    b_y=(600-m_bullet.height())*0.5;

    is_free1=true;
    b_speed=2;

    b_rect.setWidth(m_bullet.width());
    b_rect.setHeight(m_bullet.height());
    b_rect.moveTo(b_x,b_y);
}

void Bullet::UpdatePosition()
{
    //空闲状态下不需要计算坐标
    if(is_free1){
        return;
    }
    //子弹向上运动
    b_y-=b_speed;
    b_rect.moveTo(b_x,b_y);

    //如果超出屏幕
    if(b_y<=-b_rect.height()){
        is_free1=true;
    }
}

